//
//  ViewController.m
//  Dice
//
//  Created by iD Student on 7/24/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize diceValue;
@synthesize dicePic;

- (void)viewDidLoad
{
    [super viewDidLoad];
	diceValue.text = @"Dice Value";
    [dicePic setImage:[UIImage imageNamed:@"dicegame.jpeg"]];
}

- (void)viewDidUnload
{
    [self setDicePic:nil];
    [self setDiceValue:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

- (IBAction)roll:(id)sender {
    diceNumber = (arc4random() % (6)) + 1 ;
    
    int val = 0;
    
    switch(diceNumber){
        case 1:
            val = 1;
            [dicePic setImage:[UIImage imageNamed:@"1Dice.jpg"]];
            break;
        case 2:
            val = 2;
            [dicePic setImage:[UIImage imageNamed:@"2Dice.jpg"]];
            break;
        case 3:
            val = 3;
            [dicePic setImage:[UIImage imageNamed:@"3Dice.jpg"]];
            break;
        case 4:
            val = 4;
            [dicePic setImage:[UIImage imageNamed:@"4Dice.jpg"]];
            break;
        case 5:
            val = 5;
            [dicePic setImage:[UIImage imageNamed:@"5Dice.jpg"]];
            break;
        case 6:
            val = 6;
            [dicePic setImage:[UIImage imageNamed:@"6Dice.jpg"]];
            break;
    }
    diceValue.text = [NSString stringWithFormat:@"%d", val];
}
@end
